package com.kefu.call.vo;

import org.apache.commons.lang3.StringUtils;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.kefu.common.context.KefuContext;
import com.kefu.common.vo.AbstractSearchVo;
import com.kefu.call.model.CallAvoidDial;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
 * @author francis
 * @date 2022/06/19
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(description = "免打号码")
public class CallAvoidDialSearchVo extends AbstractSearchVo {

    @ApiModelProperty(value = "电话")
    private String telephone;
    @ApiModelProperty(value = "姓名")
    private String name;
    @ApiModelProperty(value = "创建时间开始")
    private Long createTimeStart;
    @ApiModelProperty(value = "创建时间结束")
    private Long createTimeEnd;

	 @Override
    public  LambdaQueryWrapper<CallAvoidDial> lambdaQuery(){
    	LambdaQueryWrapper<CallAvoidDial> wrapper=Wrappers.<CallAvoidDial>lambdaQuery();
	    wrapper.like(StringUtils.isNotBlank(telephone), CallAvoidDial::getTelephone, telephone);//电话
	    wrapper.like(StringUtils.isNotBlank(name), CallAvoidDial::getName, name);//姓名
		wrapper.ge(createTimeStart!=null, CallAvoidDial::getCreateTime, createTimeStart);//创建时间开始
		wrapper.le(createTimeEnd!=null, CallAvoidDial::getCreateTime, createTimeEnd);//创建时间结束
	    wrapper.eq(CallAvoidDial::getTenantId, KefuContext.getKefuContext().getTenantId());
	    
    	return wrapper;
	}
}